import { NodeStatus } from '../Enum'
import BTNode from './BTNode'

export default abstract class BTParent extends BTNode {
  childrens: BTNode[] = []
  private _index: number = 0

  get index() {
    return this._index
  }

  set index(index: number) {
    this._index = index
  }

  constructor(childrens: BTNode[]) {
    super()
    this.childrens = childrens
  }

  abstract canExecute(): boolean
  abstract onChildExecuted(status: NodeStatus, index: number): void

  decorate(status: NodeStatus) {
    return status
  }

  onConditionalAbort(_index: number) {}

  canRunParallelChildren(): boolean {
    return false
  }

  onChildStart() {}
}
